"""
 encoding    : utf-8
 @File       : view_survey_test.py
 @Author     : Rao
 @Version    :
 @Description: 查看调查页面执行测试用例
 @Date       : 2024/06/20
"""
import time

import pytest

from common import OA_tools
from pages.public_infomation.view_survey_page import ViewSurveyAction


@pytest.mark.usefixtures('view_survey_preset')
class TestViewSurvey:
    @pytest.mark.skip
    def test_view_survey_success(self, view_survey_preset):
        """查看调查正向验证"""
        # 解析夹具返回的数据
        page, driver = view_survey_preset
        # 打开页面
        page.tools.select(2, 4)
        action = ViewSurveyAction(page, driver)
        # 点击标题
        action.click_title()
        result = action.check_button_text()
        if result == '提交':
            action.click_check()
            action.click_vote()
            time.sleep(2)
            action.assert_pop_window_right()
        else:
            action.assert_button_text()

    @pytest.mark.skip
    def test_click_number(self, view_survey_preset):
        """检验点击次数"""
        # 解析夹具返回的数据
        page, driver = view_survey_preset
        # 打开页面
        page.tools.select(2, 4)
        action = ViewSurveyAction(page, driver)
        click_number_init = action.check_number()
        page.back_frame_root()
        action.click_title()
        action.click_close_button()
        # 第二次获取点击次数
        page.back_frame_root()
        page.click_refresh()
        click_number = action.check_number()
        action.assert_clik_number(int(click_number), int(click_number_init) + 1)

    def test_delete_survey(self, view_survey_preset):
        """删除调查"""
        # 解析夹具返回的数据
        page, driver = view_survey_preset
        # 打开页面
        page.tools.select(2, 4)
        action = ViewSurveyAction(page, driver)
        action.click_delete()
        action.second_confirmation()
        action.assert_pop_window_right()


if __name__ == '__main__':
    pytest.main(['-s', './view_survey_test.py'])
